 <template>
  <div>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="ProTypeID" label="商品分类ID"> </el-table-column>
      <el-table-column prop="ProTypeName" label="分类名称"> </el-table-column>
      <el-table-column prop="Sort" label="显示顺序"> </el-table-column>
      <el-table-column prop="CreateTime" label="添加时间"> </el-table-column>
      <el-table-column label="操作" width="300">
        <template slot-scope="scope">
          <span
            ><el-button
              @click="upt(scope.row.ProID)"
              type="primary"
              plain
              size="mini"
              icon="el-icon-edit"
              >编辑</el-button
            >
            <el-button
              @click="del(scope.row.ProID)"
              type="danger"
              size="mini"
              icon="el-icon-delete"
              plain
              >删除</el-button
            >
          </span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

   <script>
export default {
  data() {
    return {
      //显示数据
      tableData: [],
    };
  },

  mounted() {
    this.xian();
  },

  methods: {
    //显示

    xian() {
      this.axios
        .get(
          "https://localhost:44375/api/ProductType/GetProductTypes?pageIndex=1&pageSize=99"
        )
        .then((response) => {
          console.log(response.data.data.Result);
          this.tableData = response.data.data.Result;
          this.op();
        });
    },

    //删除

    del(Id) {
      this.axios
        .post("https://localhost:44375/api/ProductType/IsDel?Id=" + Id)
        .then((response) => {
          if (response.data.data == 1) {
            this.$message({
              message: "成功!",
              type: "success",
            });
          } else {
            this.$message.error("失败!");
          }
          location.reload();
        });
    },

    //跳转添加页面

    Create() {
      this.$router.push("/Product/ProductCreate");
    },

    upt() {
      this.$router.push("/Product/ProductEdit");
    },
  },
};
</script>